; http://cenalulu.github.io/images/linux/vim_cheatsheet/classic.gif
; http://ahkv2.mallocx.com/Tutorial.htm
; https://www.autohotkey.com/boards/viewforum.php?f=82&start=25
; Hotkey Resource: https://www.autohotkey.com/docs/v1/Hotkeys.htm#Symbols
; Symbol Legend - [#, ^, !, +] are modifiers
; # = Windows Key
; ^ = Ctrl
; ! = Alt
; + = Shift


;系统快捷键
CapsLock & h::
{
    send "{left}"
}

CapsLock & j::
{
    send "{down}"
}

CapsLock & k::
{
    send "{up}"
}

CapsLock & l::
{
    send "{right}"
}

CapsLock & backspace::{
static count:=0
if count>0{
    count++
    return
}
count:=1
settimer after, -400
after(){
    if count=1{
        send "{del}"
    }
    else if count=2{
         send "{home}+{end}{del}"
    }
    else if count>2{
        tooltip count
    }
    count:=0
}
}

CapsLock & -::
{
    send "{pgup}"
}

CapsLock & =::
{
    send "{pgdn}"
}

CapsLock & ,::
CapsLock & [::
{
    send "{home}"
}
CapsLock & .::
CapsLock & ]::
{
    send "{end}"
}

capslock & \::
{
	if GetKeyState("Ctrl")
		MsgBox "under control"
	else
        MsgBox "out of control"
}   

ToolTip "Timed ToolTip`nThis will be displayed for 5 seconds."
SetTimer () => ToolTip(), -5000



; Obsidia 快捷键
#HotIf winactive("ahk_exe Obsidian.exe")
^!c::MsgBox "You pressed Control+Alt+C in Notepad."
^5:: send  "{end}~~{home}~~{end}" ;删除线
^6:: send "{home}{del}{del}{end}{backspace}{backspace}" ;取消删除线
#hotif

;判断是否使用notepad2程序
#n::
{
    if WinExist("ahk_class Notepad2")
        WinActivate  ; Activate the window found above
    else
        Run "notepad"  ; Open a new Notepad window
}

;一按置顶当前窗口，再按取消之
#a::
{
	WinSetAlwaysOnTop -1, "A"
}

; ctrl+capslock组合快捷键
#HotIf GetKeyState("Ctrl")
CapsLock & h::
{
    send "+{left}"
}

CapsLock & j::
{
    send "+{down}"
}

CapsLock & k::
{
    send "+{up}"
}

CapsLock & l::
{
    send "+{right}"
}

CapsLock & -::
{
    send "+{pgup}"
}

CapsLock & =::
{
    send "+{pgdn}"
}

CapsLock & ,::
CapsLock & [::
{
    send "+{home}"
}

CapsLock & .::
CapsLock & ]::
{
    send "+{end}"
}

#hotif

;未来要做成函数
app_hotkey(keyname, app_title, app_path)
{
    activate(keyname)  ; This will be a closure due to app_title and app_path.
    {
        if WinExist(app_title)
            WinActivate
        else
            Run app_path
    }
    Hotkey keyname, activate
}
; Win+N activates or launches Notepad.
app_hotkey "#n", "ahk_class Notepad", "notepad.exe"
; Win+W activates or launches WordPad.
app_hotkey "#w", "ahk_class WordPadClass", "wordpad.exe"


Hotkey "^!z", MyFunc
MyFunc(ThisHotkey)
{
    MsgBox "You pressed " ThisHotkey, "shiny"
}
